pub mod liveness;
pub mod reg;
pub mod build;
pub mod select;
pub mod dump;
pub mod linear;
pub mod coloring;
pub mod fetch;
pub mod rewrite;
pub mod peephole;

use linear::*;
use crate::llvm::*;
use crate::riscv::*;

pub fn emit_asm(program: &LLVMProgram) -> RiscV {
    let mut asm = RiscV::new();
    program.select_asm(&mut asm);
    asm.alloc_regs::<LinearScan>();
    asm.save_registers();
    asm.deterministic_stack();
    asm.stack_alloc_free();
    asm.map_addr();
    asm.unfold_ret();

    asm.eliminate_meaningless_move();

    asm
}

